import { dialog } from '@gis/lib/components/antd-dialog';
import { BasicMarker } from '../../js/BasicMarker.js';
import { BasicMarkers } from '../../js/BasicMarkers.js';
import { getMarkerIcon } from '../../js/icon.js';
import { farmhouseMapPoint } from '@gis/lib/api';
import { useUserInfoStore } from '@gis/lib/pinia/userInfo.js';
import { handleCommonRes } from '@gis/lib/utils/resolver.js';

function getMarkerType(data = {}) {
  if (data.is_relocation_household != 1) return 'fcqf';
  return { 1: 'ybq', 2: 'wbq' }[data.removal_status];
}

class Marker extends BasicMarker {
  constructor({ map, data }) {
    super({ map, data });
    /* this.type: 这个type主要用于筛选,需要和filter-legend里面的type相对应 */
    this.type = getMarkerType(data);
    super.create();
  }
  getIcon() {
    return getMarkerIcon(this.type);
  }
  getTitle() {
    return this.data.room_name;
  }

  getLabel() {
    return '';
  }
  onClick() {
    // dialog({
    //   content: () => import('@/views/farmhouse-manage/components/farmhouse-detail.vue'),
    //   contentProps: {
    //     details: Object.assign({}, this.data, { markerType: this.type }),
    //   },
    //   dialogProps: {
    //     title: '农房详情',
    //     width: 'medium',
    //     height: 'fixed',
    //     footer: null,
    //   },
    // });
  }
}

export default class Nfgl extends BasicMarkers {
  constructor({ map }) {
    super();
    this.map = map;
    // const circle = new AMap.Circle({
    //   center: bdToGd(104.011328, 30.709803),
    //   radius: 5,
    //   fillColor: '#f00',
    // });
    // circle.setMap(this.map);
  }
  createMarker(data) {
    return new Marker({ map: this.map, data });
  }
  async getDataAsync() {
    const { area_code } = useUserInfoStore();
    const data = await handleCommonRes(farmhouseMapPoint, { area_code: area_code });
    return data.map((item) => Object.assign(item, { lnglat: [item.longitude, item.latitude] }));
  }
}
